/**
 * Copyright &copy; 2015-2020 <a href="www.dsesa.cn/">ESA</a> All rights reserved.
 */
package com.jeeplus.modules.buzz.arch2Workjcdj.web;

import com.google.common.collect.Lists;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.web.BaseController;
import com.jeeplus.modules.buzz.arch2Workjcdj.entity.Arch2Workjcdj;
import com.jeeplus.modules.buzz.arch2Workjcdj.service.Arch2WorkjcdjService;
import com.jeeplus.modules.buzz.sysno.mapper.SysNoMapper;
import com.jeeplus.modules.buzz.workjcdj.entity.Workjcdj;
import com.jeeplus.modules.buzz.workjcdj.entity.Workjcdjentry;
import com.jeeplus.modules.buzz.workjcdj.mapper.WorkjcdjentryMapper;
import com.jeeplus.modules.sys.utils.UserUtils;
import net.sf.ezmorph.object.DateMorpher;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.util.JSONUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 待检查登记Controller
 * @author 待检查登记
 * @version 2019-10-03
 */
@Controller
@RequestMapping(value = "${adminPath}/buzz/arch2Workjcdj")
public class Arch2WorkjcdjController extends BaseController {


	@Autowired
	private Arch2WorkjcdjService arch2WorkjcdjService;

	@Autowired
	private WorkjcdjentryMapper workjcdjentryMapper;

	@Autowired
    SysNoMapper sysNoMapper;

	@ModelAttribute
	public Arch2Workjcdj get(@RequestParam(required=false) String id) {
		Arch2Workjcdj entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = arch2WorkjcdjService.get(id);
		}

		if (entity == null){
			entity = new Arch2Workjcdj();
		}
		return entity;
	}

	/**
	 * 待检查登记列表页面arch2TempKKList"
	 */
	@RequestMapping(value = {"list", ""})
	public String list(Arch2Workjcdj arch2Workjcdj, Model model) {
		model.addAttribute("arch2Workjcdj", arch2Workjcdj);
		return "modules/buzz/arch2Workjcdj/arch2WorkjcdjList";
	}

	/**
	 * 待检查登记列表数据
	 */
	@ResponseBody
	@RequestMapping(value = "data")
	public Map<String, Object> data(Arch2Workjcdj arch2Workjcdj, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<Arch2Workjcdj> page = arch2WorkjcdjService.findPage(new Page<Arch2Workjcdj>(request, response), arch2Workjcdj);
		return getBootstrapData(page);
	}

	/**
	 * 生成车辆档案表单页面
	 */
	/*@RequestMapping(value = "formGenerate")
	public String formGenerate(@RequestParam(value = "ids",required=false) String ids,  Model model) {
		Workjcdj carStockFc = new Workjcdj();
		Date date = new Date();
		if(StringUtils.isNotBlank(ids)){
			String idArray[] =ids.split(",");
			List<Workjcdjentry> list = workjcdjentryMapper.getById(idArray,date);
			if(list != null && list.size() > 0){
				carStockFc.setArchives(list.get(0).getArchives());
				carStockFc.setBuytype(list.get(0).getBuytype());
				carStockFc.setWorkjcdjEntryList(list);
			}
		}

		model.addAttribute("carStockFc", carStockFc);
		return "modules/buzz/carstockfc/carStockFcForm";
	}*/
}
